<?php
/**
 * Holds Image_RLEObj
 *
 * @author daantimmer
 *
 * @package Library
 * @subpackage Image
 */

/**
 * Object representing a RLE-color
 *
 * @author daantimmer
 */
class Image_RLEObj{
	
	/**
	 * Run-length of this color
	 * @var integer
	 */
	private $length;
	
	/**
	 * @var Image_Lib_Color
	 */
	private $col;
	
	/**
	 * @see Image_ColorIndex
	 * @var int Image_ColorIndex
	 */
	private $index;

	/**
	 * Constructor
	 *
	 * @param Image_Lib_Color $col
	 * @param integer $index
	 * @param integer $length
	 * @return void
	 */
	public function __construct(Image_Lib_Color $col, /** int */ $index, /** int */ $length = 1){
		$this->col = $col;
		$this->length = $length;
		$this->index = $index;
	}
	
	/**
	 * Increments current length by $incr (default = 1)
	 * @param integer $incr (default = 1)
	 * @return void
	 */
	public function incr($incr = 1){
		$this->length += $incr;
	}
	
	/**
	 * returns current run-length
	 * @return integer
	 */
	public function length(){
		return $this->length;
	}
	
	/**
	 * @param Image_Lib_Color $col
	 * @return void
	 */
	public function setColor(Image_Lib_Color $col){
		$this->col = $col;
	}
	
	/**
	 * Alias for getColor
	 *
	 * @see RLEObj::getColor()
	 * @deprecated use RLEObj::getColor() instead
	 * @return Image_lib_Color
	 */
	public function color(){
		return $this->getColor();
	}
	
	/**
	 * Returns current color
	 *
	 * @return Image_Lib_Color
	 */
	public function getColor(){
		return $this->col;
	}
	
	/**
	 * Sets Image_ColorIndex
	 *
	 * @see Image_ColorIndex
	 * @param integer $index defined by Image_ColorIndex
	 * @return void
	 */
	public function setIndex($index){
		$this->index = $index;
	}
	
	/**
	 * Returns Image_ColorIndex index
	 *
	 * @see Image_ColorIndex
	 * @return integer defined by Image_ColorIndex
	 */
	public function getIndex(){
		return $this->index;
	}
}